﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RabbitMQ.Client;

namespace Producer
{
    class Program
    {
        static void Main(string[] args)
        {
            PublishLutronResponse();
        }

        private static void PublishNormalMessage()
        {
            var connectionFactory = new ConnectionFactory();
            using (IConnection connection = connectionFactory.CreateConnection())
            {
                using (IModel channel = connection.CreateModel())
                {
                    channel.QueueDeclare("hello-world-queue", false, false, false, null);

                    while (true)
                    {
                        Console.WriteLine("Enter your message or press enter to exit..");
                        string message = Console.ReadLine();
                        if (string.IsNullOrEmpty(message) || string.IsNullOrEmpty(message.Trim())) break;

                        byte[] bytes = Encoding.UTF8.GetBytes(message);
                        channel.BasicPublish(string.Empty, "hello-world-queue", null, bytes);

                    }
                }
            }
        }
        private static void PublishLutronResponse()
        {
            var connectionFactory = new ConnectionFactory();
            using (IConnection connection = connectionFactory.CreateConnection())
            {
                using (IModel channel = connection.CreateModel())
                {
                    while (true)
                    {
                        Console.WriteLine("Enter your message or press enter to exit..");
                        string message = Console.ReadLine();
                        if (string.IsNullOrEmpty(message) || string.IsNullOrEmpty(message.Trim())) break;

                        byte[] bytes = Encoding.UTF8.GetBytes(message);
                        channel.BasicPublish("lutron.quantum", "project.1.response.1", null, bytes);
                    }
                }
            }
        }
    }
}
